package internetware.androidclient;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class Set extends Activity{
	private String pfile = "internetwareclientsetting";
	private String server;
	private String timeout;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.set);
		Intent i =getIntent();
		server = i.getStringExtra("server");
		timeout = i.getStringExtra("timeout");
		EditText e1 = (EditText) findViewById(R.id.server);
		e1.setText(server);
		EditText e2 = (EditText) findViewById(R.id.timeout);
		e2.setText(timeout);
		
		Button b1 = (Button) findViewById(R.id.set_actual);
		b1.setOnClickListener(new OnClickListener(){
			@Override
			public void onClick(View v) {
				EditText e1 = (EditText) findViewById(R.id.server);
				EditText e2 = (EditText) findViewById(R.id.timeout);
				server = e1.getText().toString();
				timeout = e2.getText().toString();
				SharedPreferences sp = getSharedPreferences(pfile,0);
				Editor e = sp.edit();
				e.putString("server", server);
				e.putString("timeout", timeout);
				e.commit();
				Intent i  =new Intent("clientandroid.completesetting");
				i.putExtra("server", server);
				i.putExtra("timeout", timeout);
				sendBroadcast(i);
				finish();
			}		
		});
		Button b2= (Button)findViewById(R.id.cancel);
		b2.setOnClickListener(new OnClickListener(){
			@Override
			public void onClick(View v) {
				finish();
			}			
		});
	}
	
}
